#include "controlwidget.h"
#include "ui_controlwidget.h"
#include "smartwidget.h"
#include "loginwidget.h"


#define w   320
#define h   200

controlWidget::controlWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::controlWidget)
{
    ui->setupUi(this);

    this->setMaximumSize(1070,730);
    this->setMinimumSize(1070,730);

    QPalette pal;
    pal.setBrush(QPalette::Background,QBrush(QPixmap(QString(":/new/prefix1/images/bg.png")).scaled(1070,730)));
    this->setPalette(pal);

    //客厅
    keting = new QPushButton(this);
    //keting->resize(w,h);
    keting->setIcon(QIcon(QPixmap(QString(":/new/prefix1/images/keting.png")).scaled(w,h)));
    keting->setIconSize(QSize(w,h));
    keting->setFixedSize(w,h);

    //卧室一
    woshi1 = new QPushButton(this);
    //woshi1->resize(w,h);
    woshi1->setIcon(QIcon(QPixmap(QString(":/new/prefix1/images/woshiyi.png")).scaled(w,h)));
    woshi1->setIconSize(QSize(w,h));
    woshi1->setFixedSize(w,h);
    //车库
    cheku = new QPushButton(this);
    //cheku->resize(w,h);
    cheku->setIcon(QIcon(QPixmap(QString(":/new/prefix1/images/cheku1.png")).scaled(w,h)));
    cheku->setIconSize(QSize(w,h));
    cheku->setFixedSize(w,h);
    //地下室
    dixiashi = new QPushButton(this);
    //dixiashi->resize(w,h);
    dixiashi->setIcon(QIcon(QPixmap(QString(":/new/prefix1/images/dixiashi.png")).scaled(w,h)));
    dixiashi->setIconSize(QSize(w,h));
    dixiashi->setFixedSize(w,h);
    //卧室二
    woshi2 = new QPushButton(this);
    //woshi2->resize(w,h);
    woshi2->setIcon(QIcon(QPixmap(QString(":/new/prefix1/images/woshier.png")).scaled(w,h)));
    woshi2->setIconSize(QSize(w,h));
    woshi2->setFixedSize(w,h);
    //厨房
    chufang = new QPushButton(this);
    //chufang->resize(w,h);
    chufang->setIcon(QIcon(QPixmap(QString(":/new/prefix1/images/chufang.png")).scaled(w,h)));
    chufang->setIconSize(QSize(w,h));
    chufang->setFixedSize(w,h);
    //外景
    waijing = new QPushButton(this);
    //waijing->resize(w,h);
    waijing->setIcon(QIcon(QPixmap(QString(":/new/prefix1/images/waijing.png")).scaled(w,h)));
    waijing->setIconSize(QSize(w,h));
    waijing->setFixedSize(w,h);
    //卧室三
    woshi3 = new QPushButton(this);
    //woshi3->resize(w,h);
    woshi3->setIcon(QIcon(QPixmap(QString(":/new/prefix1/images/woshisan.png")).scaled(w,h)));
    woshi3->setIconSize(QSize(w,h));
    woshi3->setFixedSize(w,h);
    //外大门
    waidamen = new QPushButton(this);
    //waidamen->resize(w,h);
    waidamen->setIcon(QIcon(QPixmap(QString(":/new/prefix1/images/waidamen.png")).scaled(w,h)));
    waidamen->setIconSize(QSize(w,h));
    waidamen->setFixedSize(w,h);
    //返回
    back = new QPushButton(this);
    back->setIcon(QIcon(QPixmap(QString(":/new/prefix1/images/back.png")).scaled(50,30)));
    back->setIconSize(QSize(50,30));
    back->setFixedSize(50,30);



    mainlayout = new QGridLayout(this);
    mainlayout->addWidget(keting,0,0);
    mainlayout->addWidget(woshi1,0,1);
    mainlayout->addWidget(cheku,0,2);
    mainlayout->addWidget(dixiashi,1,0);
    mainlayout->addWidget(woshi2,1,1);
    mainlayout->addWidget(chufang,1,2);
    mainlayout->addWidget(waijing,2,0);
    mainlayout->addWidget(woshi3,2,1);
    mainlayout->addWidget(waidamen,2,2);

    mainlayout->setHorizontalSpacing(5);
    mainlayout->setVerticalSpacing(5);
    mainlayout->setContentsMargins(50,40,50,80);

    this->setLayout(mainlayout);

    //链接信号与槽
    connect(keting,SIGNAL(clicked(bool)),this,SLOT(ketingBtnSlot()));
    connect(back,SIGNAL(clicked(bool)),this,SLOT(backSlot()));

}

controlWidget::~controlWidget()
{
    delete ui;
}

void controlWidget::ketingBtnSlot()
{
    this->close();
    smartwidget *r = new smartwidget();
    r->show();
}

void controlWidget::backSlot()
{
    this->close();
    LoginWidget *r = new LoginWidget();
    r->show();
}
